{{define "index/index.html"}}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>golang wubuze</title>
    <link href="/static/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/blog-home.css" rel="stylesheet">
    <link href="/static/css/base.css" rel="stylesheet">
</head>

<body>
{{/*<h1>{{.test}}</h1>*/}}
{{/*<h1>{{.name}}</h1>*/}}
{{template "nav.html" .}}

<div class="container">
    <div class="row">

        <div class="col-md-8">
            <section class="article">
                {{range $postkey,$postvalue:=.posts}}
                    <div class="articleInfo">
                        <span>
                            <a class="articleTitle" href="/post/{{$postvalue.ID}}">
                                {{$postvalue.Title}}
                            </a>
                        </span>
                            <span class="createdTime" style="margin-right: 10px;">
                            {{ $postvalue.CreatedAt }}
                        </span>
                    </div>

                    <div class="articleBody">
                        {{$length := len $postvalue.Body}}
                        {{if ge $length 100}}
                            {{truncate $postvalue.Body 100}}...
                        {{else}}
                            {{$postvalue.Body}}
                        {{end}}
                    </div>

                    <!-- article tags -->
                    <div style="margin-top: 10px">
                        <tr>
                            {{range $tagkey,$tagvalue:=$postvalue.Tags}}
                                <a href="/tag/{{$tagvalue.ID}}" class="changeTag"
                                   style="color: #888888;text-decoration: none;">
                                    # <span>{{$tagvalue.Name}}</span>&nbsp;&nbsp;
                                </a>
                            {{end}}
                        </tr>
                    </div><!-- article tags -->
                    <hr>

                {{end}}
            </section>



            {{if le .pageIndex .totalPage}}
                <ul class="pager">
                    {{if le .pageIndex 1}}
                        <li class="disabled"><a href="#">上一页</a></li>
                    {{else}}
                        <li class=""><a href="{{.path}}?page={{minus .pageIndex 1}}">上一页</a></li>
                    {{end}}
                    <li>{{ .pageIndex }}/ {{ .totalPage }}</li>
                    {{if lt .pageIndex .totalPage }}
                        <li class=""><a href="{{.path}}?page={{add .pageIndex 1}}">下一页</a></li>
                    {{ else}}
                        <li class="disabled"><a href="#">下一页</a></li>
                    {{end}}
                </ul>
            {{end}}

        </div>
        <!-- Blog Sidebar Widgets Column -->
        <div class="col-md-4">

            <!-- Blog Categories Well -->
            <div class="well">
                <h5><span class="glyphicon glyphicon-tag"></span> 文章标签</h5>
                <div class="row">
                    <div class="col-lg-6">
                        <ul class="list-unstyled">
                            {{range $tagkey,$tagvalue:=.tags}}
                                {{if isEven $tagkey}}
                                    <li><a href="/tag/{{$tagvalue.ID}}">{{$tagvalue.Name}}({{$tagvalue.Total}})</a>
                                    </li>
                                {{end}}
                            {{end}}
                        </ul>
                    </div>
                    <!-- /.col-lg-6 -->
                    <div class="col-lg-6">
                        <ul class="list-unstyled">
                            {{range $tagkey,$tagvalue:=.tags}}
                                {{if isOdd $tagkey}}
                                    <li><a href="/tag/{{$tagvalue.ID}}">{{$tagvalue.Name}}({{$tagvalue.Total}})</a>
                                    </li>
                                {{end}}
                            {{end}}
                        </ul>
                    </div>
                    <!-- /.col-lg-6 -->
                </div>
                <!-- /.row -->
            </div>

            <!-- Side Widget Well -->
{{/*            文章归档*/}}

            <div class="well">
                <h5><span class="glyphicon glyphicon-fire"></span> 阅读最多</h5>
                <div class="row">
                    <div class="col-lg-12">
                        <ul class="list-unstyled">
                            {{range $key,$post:=.maxReadPosts}}
                                <li><a href="/post/{{$post.ID}}">{{$post.Title}}({{$post.View}})</a></li>
                            {{end}}
                        </ul>
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
            </div>



        </div>




    </div>
</div>
{{template "footer.html"}}
</body>
{{end}}